import mongoose from '../dbHelper';
import { defaultSchemaExtend, defaultSchemaOptions } from "../config/index";

const Schema = mongoose.Schema;

const AiOrderSchema = new Schema(Object.assign({
    func_type: {
        type: String,
        required: true
    },
    func_name: {
        type: String,
        required: true
    },
    ai_user_id: {
        type: Schema.Types.ObjectId,
        ref: 'AiUser'
    },
    // 订单状态
    status: {
        type: String,
        required: false,
        default: '0' // 0:待支付 1:已支付 2:已取消 3:已退款 4:已发货 5:已收货 6:已完成
    },
    sys_type: {
        type: String,
        required: false,
        default: '0' // 0:小程序 1:H5 2:PC
    },
    // 店铺id
    shop_id: {
        type: Schema.Types.ObjectId,
        ref: 'Shop'
    },
    // 使用积分数量
    use_points: {
        type: Number,
        required: false,
        default: 0
    },
    // 白底图记录id
    white_id: {
        type: String,
        required: false
    },
    // 创建项目ID
    create_id: {
        type: String,
        required: false
    },
    charge: {
        type: String, // 0-免费 1-收费
        required: true,
        default: '1',
    },
    // 按类似收费
    similarCharge: {
        type: String, // 0 按次数收费 1 按图片张数收费
        required: true,
        default: '1',
    },
    // 划线积分
    linenum: {
        type: Number, // 划线积分
        required: true,
    },
    // 生成进度情况
    progress: {
        type: String, // 0-未开始 1-进行中 2-已完成
        required: true,
        default: '0',
    },
    image_num: {
        type: Number, // 生成图片张数
        required: true,
    },
    info_key: {
        type: String, // 生成图片张数
        required: false,
    },
    goods_id: {
        type: String, // 生成图片张数
        required: false,
    },
    progresslist: {
        type: Array,
        required: false,
    }


}, defaultSchemaExtend), defaultSchemaOptions);

const AiOrder = mongoose.model('AiOrder', AiOrderSchema, 'AiOrders');

export default AiOrder